/**
 * 生成目录相关的状态
 *
 * @param {StoreType} store 状态：
 * - dirTreeComputed 用于左侧目录展示的目录树
 * - dirSelected 当前选中的目录
 * - currentConfListComputed 当前选中的目录下的配置数据列表
 */
export const genDirStatus = (store: StoreType) => {
  const dirTreeComputed: ComputedRef<BaseModelTreeType> = computed(() => [
    genDirAll(store.getList().length),
    ...store.getDirTree()
  ])
  const dirSelected: Ref<string> = ref<string>(DirIdConst.All)
  const currentConfListComputed: ComputedRef<BaseModelTreeNodeType[]> = computed(() => {
    return dirSelected.value === DirIdConst.All
      ? store.getList()
      : store.getTreeMap()[dirSelected.value]?.children || []
  })

  return {
    dirTreeComputed,
    dirSelected,
    currentConfListComputed
  }
}
